/*
 * Copyright (c) 2010, Andrea Palloni
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * - Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * - Neither the name of the copyright holder nor the names of its contributors may be used
 * 	  to endorse or promote products derived from this software without specific prior written
 *    permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package net.palla.biblio.server.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Text;

/**
 * This class represents a Book Entity
 * @author andrea
 *
 */
@PersistenceCapable(detachable="true")
public class BookEntity {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;
	@Persistent
	private String title;
	@Persistent
	private String subtitle;
	@Persistent
	private Key publisher;
	@Persistent
	private Integer pages;
	@Persistent
	private String isbn;
	@Persistent
	private String issn;
	@Persistent
	private Key cdd;
	@Persistent
	private Date frontdate;
	@Persistent
	private Date pubdate;
	@Persistent
	private Integer copyryear;
	@Persistent
	private Integer printyear;
	@Persistent
	private String pubplace;
	@Persistent
	private String coll1;
	@Persistent
	private String coll2;
	@Persistent
	private Text notes;

	//Authors
	@Persistent
	private List<Key> authors = new ArrayList<Key>();
	
	//Curatori (how's the English term?)	
	@Persistent
	private List<Key> curatori = new ArrayList<Key>();	

	public Key getId() {
		return id;
	}
	public void setId(Key id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
		if (this.title != null)
			this.title = this.title.toUpperCase();
	}
	public String getSubtitle() {
		return subtitle;
	}
	public void setSubtitle(String subtitle) {
		this.subtitle = subtitle;
		if (this.subtitle != null)
			this.subtitle = this.subtitle.toUpperCase();
	}
	public Key getPublisher() {
		return publisher;
	}
	public void setPublisher(Key publisher) {
		this.publisher = publisher;
	}
	public Integer getPages() {
		return pages;
	}
	public void setPages(Integer pages) {
		this.pages = pages;
	}
	public String getIsbn() {
		return isbn;
	}
	public void setIsbn(String isbn) {
		this.isbn = isbn;
		if (this.isbn != null)
			this.isbn = this.isbn.toUpperCase();
	}
	public String getIssn() {
		return issn;
	}
	public void setIssn(String issn) {
		this.issn = issn;
		if (this.issn != null)
			this.issn = this.issn.toUpperCase();
	}
	public Key getCdd() {
		return cdd;
	}
	public void setCdd(Key cdd) {
		this.cdd = cdd;
	}
	public Date getFrontdate() {
		return frontdate;
	}
	public void setFrontdate(Date frontdate) {
		this.frontdate = frontdate;
	}
	public Date getPubdate() {
		return pubdate;
	}
	public void setPubdate(Date pubdate) {
		this.pubdate = pubdate;
	}
	public Integer getCopyryear() {
		return copyryear;
	}
	public void setCopyryear(Integer copyryear) {
		this.copyryear = copyryear;
	}
	public Integer getPrintyear() {
		return printyear;
	}
	public void setPrintyear(Integer printyear) {
		this.printyear = printyear;
	}
	public String getPubplace() {
		return pubplace;
	}
	public void setPubplace(String pubplace) {
		this.pubplace = pubplace;
		if (this.pubplace != null)
			this.pubplace = this.pubplace.toUpperCase();
	}
	public String getColl1() {
		return coll1;
	}
	public void setColl1(String coll1) {
		this.coll1 = coll1;
		if (this.coll1 != null)
			this.coll1 = this.coll1.toUpperCase();
	}
	public String getColl2() {
		return coll2;
	}
	public void setColl2(String coll2) {
		this.coll2 = coll2;
		if (this.coll2 != null)
			this.coll2 = this.coll2.toUpperCase();
	}
	public Text getNotes() {
		return notes;
	}
	public void setNotes(Text notes) {
		this.notes = notes;
	}
	public List<Key> getAuthors() {
		return authors;
	}
	public void setAuthors(List<Key> authors) {
		this.authors = authors;
	}

	public List<Key> getCuratori() {
		return curatori;
	}
	public void setCuratori(List<Key> curatori) {
		this.curatori = curatori;
	}

}
